<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../taglibs.jsp" %>
<script type="text/javascript">
	$(function() {
		$("#query").click(function() {
			
			$("form:first").submit();
		});
	});
	function popAddEmp(){
	
		var diag = new Dialog();
		diag.Width = 850;
		diag.Height = 300;
		diag.Title = "添加员工";
		diag.URL = "${path}/emp_input";
		diag.OKEvent = function(){
			//获得子页面的文档内容对象
			 var doc=diag.innerFrame.contentWindow;
			//alert(doc.age)
			var result = doc.submitAddEmp();
			if(result == "yes"){
				diag.close();
				window.location.href="${path}/emp_list";
			}
			//diag.close();
			//window.location.href="${path}/emp_list";
		};
		diag.show();
		/* var doc=diag.innerFrame.contentWindow.document;
		doc.open(); */
		
		
	}
	
	function grantRole(empId){
		var diag = new Dialog();
		diag.Width = 850;
		diag.Height = 300;
		diag.Title = "分配角色";
		diag.URL = "${path}/role_poplist?erpQuery.empId="+empId;
		diag.OKEvent = function(){
			
			//获得子页面的文档内容对象
			 var doc=diag.innerFrame.contentWindow;
			 var result = doc.grantRole(empId);
			 if(result == "yes"){
				 diag.close();
			 }
		};
		diag.show();
		
	}
</script>
<div class="content-right">
	<div class="content-r-pic_w">
		<div style="margin:8px auto auto 12px;margin-top:6px">
			<span class="page_title">员工管理</span>
		</div>
	</div>
	<div class="content-text">
		<form action="${path }/emp_list" method="post">
			<div class="square-o-top">
				<table width="100%" border="0" cellpadding="0" cellspacing="0"
					style="font-size:14px; font-weight:bold; font-family:"黑体";">
					<tr>
						<td height="30">用&nbsp;户&nbsp;名</td>
						<td>
							<s:textfield size="14" name="erpQuery.username"></s:textfield>
						</td>
						<td>真实姓名</td>
						<td><s:textfield size="14" name="erpQuery.name"></s:textfield></td>
						<td>电&nbsp;&nbsp;&nbsp;&nbsp;话</td>
						<td><s:textfield size="14" name="erpQuery.tel"></s:textfield></td>
						<td>性&nbsp;&nbsp;&nbsp;&nbsp;别</td>
						<td>
							<s:select cssClass="kuan" list="#{'1':'男','2':'女'}" headerKey="" headerValue="----请-选-择----" name="erpQuery.gender"></s:select>
						</td>
							
						<td width="70"><a href="javascript:void(0)" onclick="popAddEmp()"> <img src="${path}/images/can_b_02.gif" border="0" /> </a></td>
					</tr>
					<tr>
						<td  height="30">电子邮件</td>
						<td><s:textfield size="14" name="erpQuery.email"></s:textfield></td>
						<td>出生日期</td>
						<td>
							<s:textfield size="14" onfocus="c.showMoreDay=false;c.show(this);" readonly="true" name="erpQuery.startBirth"></s:textfield>
						</td>
						<td>出生日期</td>
						<td>
							<s:textfield size="14" onfocus="c.showMoreDay=false;c.show(this);" readonly="true" name="erpQuery.endBirth"></s:textfield>
						</td>
						<td>部门名称</td>
						<td>
							
							<s:select cssClass="kuan" list="#dlist" name="erpQuery.depId" headerKey="" headerValue="----请-选-择----" listKey="depId" listValue="name"></s:select>
						</td>
						<td><a id="query"> <img src="${path}/images/can_b_01.gif" border="0" /> </a></td>
					</tr>
				</table>
			</div>
			<!--"square-o-top"end-->
			<div class="square-order">
				<table width="100%" border="1" cellpadding="0" cellspacing="0">
					<tr align="center"
						style="background:url(${path}/images/table_bg.gif) repeat-x;">
						<td width="8%" height="30">用户名</td>
						<td width="8%">真实姓名</td>
						<td width="5%">性别</td>
						<td width="12%">出生日期</td>
						<td width="10%">电话</td>
						<td width="12%">电子邮件</td>
						<td width="9%">所属部门</td>
						<td width="20%">操作</td>
					</tr>
					<s:iterator value="#page.list" var="emp">
					<tr align="center" bgcolor="#FFFFFF">
							<!-- 在pageContext的域对象中定义一个gender值 -->
							<s:set var="gender" value="#emp.gender"></s:set>
							<td width="13%" height="30"><s:property value="#emp.username"/></td>
							<td><s:property value="#emp.name"/></td>
							<td><e:getTxt type="gender" value="${gender }"></e:getTxt></td>
							<td><s:date name="#emp.birthday" format="yyyy-MM-dd"/></td>
							<td><s:property value="#emp.tel"/></td>
							<td><s:property value="#emp.email"/></td>
							<td><s:property value="#emp.dep.name"/></td>
							<td>
								<img src="${path}/images/icon_3.gif" /> 
								<span style="line-height:12px; text-align:center;"> 
									<a onclick="grantRole(<s:property value="#emp.empId"/>)" href="#" class="xiu">分配角色</a>
								</span> 
								<img src="${path}/images/icon_3.gif" /> 
								<span style="line-height:12px; text-align:center;"> 
									<a href="./input.jsp" class="xiu">修改</a>
								</span> 
								<img src="${path}/images/icon_04.gif" /> 
								<span style="line-height:12px; text-align:center;"> 
									<a href="javascript:void(0)" class="xiu" onclick="showMsg('是否删除该项数据？',318)">删除</a>
								</span>
							</td>
						</tr>
					</s:iterator>
					
				</table>
				<%@include file="../tools/paging.jsp" %>
			</div>
		</form>
	</div>
	<div class="content-bbg"></div>
</div>
